<!DOCTYPE html>
<html>
<head lang="en">
  <meta charset="UTF-8">
  <title>公交查询首页</title>
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
  <meta name="format-detection" content="telephone=no">
  <meta name="renderer" content="webkit">
  <meta http-equiv="Cache-Control" content="no-cache" />
  
  <meta http-equiv="Pragma" content="no-cache"> 
<meta http-equiv="Expires" content="0"> 

  <link rel="alternate icon" type="image/png" href="assets/i/favicon.png">

  <link rel="stylesheet" href="assets/css/amaze.min.css">
<link rel="stylesheet" href="assets/css/amazeui.min.css">
<link rel="stylesheet" href="assets/fonts2/iconfont.css">
<link rel="stylesheet" href="assets/css/app.css">
  <script src="assets/js/jquery.min.js"></script>
<script src="assets/js/handlebars.min.js"></script>
<script src="assets/js/amazeui.min.js"></script>
<script src="assets/js/jquery.bpopup.min.js"></script>
<script src="assets/js/app.js"></script>

<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=W7L9pFfPKrkMlRO0EHuLoxWd"></script>

<style>
	body{
		padding-bottom:50px;
		position:static;
	}
	.search-content{
		padding: 1rem;
		background-color: #f5f5f5;
	}
	.am-content{
		background:#FFFFFF;
		border-top:1px solid #d6d6d6;
	}
	
	.history{
		background:#FFFFFF;
		border-top:1px solid #d6d6d6;
		display:none;
	}
	
	input{
		border-radius: 5px 5px;
		border: 1px solid #E4DADA;
		line-height: 3rem;
		width: 100%;
		padding: 0px 1rem;
	}

	.icon-search{
		position: absolute;
		right: 20px;
		margin-top: 2px;
		color:#dcdcdc;
		padding: 0px 1rem;
	}
	
	.icon-loadd{
		position: absolute;
		right: 20px;
		margin-top: 2px;
		color:#dcdcdc;
		padding: 0px 1rem;
	}
	.icon-refresh{
		color:#dcdcdc;
	}
	
	table{
		width:100%;
	}
	.item{
		padding: .8rem;
		border-bottom:1px solid #EFEEEE;
		color:#9b9b9b;
	}
	.number{
		color:#fab34d;
	}
	
	.item .title{
		color:#3d4245;
	}
	.item .title .spanright{
		float:right;
		color:#cccccc;
		font-size:1.6rem;
	}
	.item .title .iconfont{
		color:#5eacf6;
	}

	.item .content .line{
		padding: .8rem;
		height: inherit;
		background: transparent;
		font-size: 1.6rem;
		border-top:1px solid #EFEEEE;
	}
	.am-btn-default{
		background-color: #FFFFFF;
	    width: 80%;
	    margin-top: 20px;
	    border-radius: 5px;
	}
	.footer{
		position: fixed;
		bottom:0;
		left:0;
		width:100%;
		z-index:100;
		background-color:#f5f5f5;
		border-top:1px solid #EFEEEE;
		height:50px;
		padding:0px 2%;
	}
	.head{
		position:absolute;
		top:0;
		left:0;
		width:100%;
		z-index:100;
	}
	.line ul {
		list-style: none;
		padding:0px;
	}
	.line li {
		float:left;
		padding-left:10px;
		vertical-align: middle;
	}
	.notice{
		padding:10px;
		line-height:15px;
		border-bottom:1px solid #d6d6d6;
		font-size:1.3rem;
		color:#FBBA5E;
		background-color:#FEF2D0;
		text-align: left;
		overflow: hidden;
		display: none;
	}
	
	.b-close{
		border-radius: 7px 7px 7px 7px;
	    box-shadow: none;
	    font: bold 131% sans-serif;
	    padding: 0 6px 2px;
	    position: absolute;
	    right: -5px;
	    top: -5px;
	}
	
	.button{
		background-color: #2b91af;
	    border-radius: 10px;
	    box-shadow: 0 2px 3px rgba(0,0,0,0.3);
	    color: #fff;
	    cursor: pointer;
	    display: inline-block;
	    padding: 5px 15px;
	    text-align: center;
	    text-decoration: none;
	}
	.bpopup{
		display:none;
		border-radius:15px;
		width:70%;
		height:60%;
		padding:30px;
		box-shadow: 0 0 25px 5px #999;
		color:#ffffff;
		
		FILTER: progid:DXImageTransform.Microsoft.Gradient(gradientType=0,startColorStr=#54AAF9,endColorStr=#98E7F6); /*IE 6 7 8*/ 

		background: -ms-linear-gradient(top, #54AAF9,  #98E7F6);        /* IE 10 */
		
		background:-moz-linear-gradient(top,#54AAF9,#98E7F6);/*火狐*/ 
		
		background:-webkit-gradient(linear, 0% 0%, 0% 100%,from(#54AAF9), to(#98E7F6));/*谷歌*/ 
		
		background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#54AAF9), to(#98E7F6));      /* Safari 4-5, Chrome 1-9*/
		
		background: -webkit-linear-gradient(top, #54AAF9, #98E7F6);   /*Safari5.1 Chrome 10+*/
		
		background: -o-linear-gradient(top, #54AAF9, #98E7F6);  /*Opera 11.10+*/
	}
	p{
	 text-indent:2em;
	}
</style>

</head>

<body>
<header class="demo-bar head"><a href="javascript:;" id="back" class="icon iconfont icon-left demo-icon-home"></a><h1>线路查询</h1></header>
	<div style="margin-top: 50px;">
		<div class="notice"><marquee direction=left scrollamount=5 onclick="changeStatus(this);"></marquee></div>
		<div class="search-content">
			<input type="text" class="" id="keyword" placeholder="请输入站点名称或线路名称"><i id="searchicon" class="icon iconfont icon-search"></i>
		</div>
		<div class="am-content">
			
			<div class="item fujin">
				<table>
					<tr>
						<td><div style="font-size: 1.5rem;padding-top: .8rem;">附近站点<label class="number" id="number">0</label>个</div></td>
						<td align="right"><i class="icon iconfont icon-refresh"></i></td>
					</tr>
				</table>
			</div>
			<div id="list">
				
			</div>
			
	
		</div>
	</div>
	<div class="history">
		<div class="item">
			<table>
				<tr>
					<td><div style="font-size: 1.5rem;padding-top: .8rem;">搜索历史</div></td>
					<td align="right"></td>
				</tr>
			</table>
		</div>
		<div id="historylist">
		
		</div>
		<div id="clearHistory" align="center" style="padding:10px;color:#cccccc;" onclick="clearHistory();">清空搜索历史</div>
	</div>
	<!-- 智能匹配 -->
	<div class="sites">
		<div class="item">
			<table>
				<tr>
					<td><div style="font-size: 1.5rem;padding-top: .8rem;"></div></td>
					<td align="right"></td>
				</tr>
			</table>
		</div>
	</div>	
	
	
	<div class="am-modal am-modal-no-btn" tabindex="-1" id="streamModal">
		<div class="am-modal-dialog">
			<div class="am-modal-hd">
				线路<a href="javascript: void(0)" class="am-close am-close-spin"
					data-am-modal-close>&times;</a>
			</div>
			<div class="am-modal-bd">
				
				<input type="hidden" id="lineId"/>
				<input type="hidden" id="siteId"/>
				
				<div id="streamContent">
					
				</div>
						
				<div>
					<button class="am-btn am-btn-default" data-am-modal-close>取消</button>
				</div>
			</div>
		</div>
	</div>
	<footer class="footer">
		<div id="sy" style="width:32%;float:left;text-align:center;color:#1a7de2;">
			<ul style="list-style:none;">
				<li><i class="icon iconfont icon-bus" style="font-size:24px;line-height:30px;top:0px;"></i></li>
				<li style="line-height:15px;"><span style="font-size:12px;">线路查询</span></li>
			</ul>
		</div>
		<div id="xlgh" style="width:32%;float:left;text-align:center;color:#9b9b9b;">
			<ul style="list-style:none;">
				<li><i class="icon iconfont icon-guiji" style="font-size:24px;line-height:30px;top:0px;"></i></li>
				<li style="line-height:15px;"><span style="font-size:12px;">线路规划</span></li>
			</ul>
		</div>
		<div id="wdsc" style="width:32%;float:left;text-align:center;color:#9b9b9b;">
			<ul style="list-style:none;">
				<li><i class="icon iconfont icon-user" style="font-size:22px;line-height:30px;top:0px;"></i></li>
				<li style="line-height:15px;"><span style="font-size:12px;">我的收藏</span></li>
			</ul>
		</div>
	</footer>
	<div id="element_to_pop_up" class="bpopup">
		<span class="button b-close"><span>X</span></span>
		<p id="news"></p>
		<img src="images/background.png" width="100px" height="100px" style="position:absolute;right:10px;bottom:10px;"/>
	</div>
	

	<script id="list-site-templ" type="text/x-handlebars-template">
      {{#each result}}
			<div class="item" data-siteId = "{{siteId}}">
				
				<div class="title">
					<span><i class="icon iconfont icon-lubiao"></i>{{siteName}}</span>
					<span class="spanright fujin">附近{{distance}}m</span>
				</div>
				<div class="content" data-siteId = "{{siteId}}" data-siteName="{{siteName}}">
					<i class="icon iconfont icon-loadd am-animation-spin"></i>
				</div>
				
			</div>
      {{/each}}
	</script>
	
	

	<script id="list-line-templ" type="text/x-handlebars-template">
		{{#each result}}
			<div class="line" lineId="{{lineId}}" siteId="{{#siteId}}" lineSiteId="">
				<div style="float:right;">
					<ul>
						<li></li>
						<li><span style="border:1px solid #EFEEEE;"></span></li>
						<li>
							<img src="images/qxshouc.png" width="20xp" height="20px" onclick="shouc(this, {{lineId}})" style="display:{{sc_display}};"/>
							<img src="images/shouc.png" width="20xp" height="20px" onclick="qxshouc(this, {{lineId}})" style="display:{{qxsc_display}};"/>
						</li>
					</ul>
				</div>
				<div onclick="selectStream({{lineId}},this);">{{lineName}}</div>
				<div style="clear:both;"></div>
			</div>
		{{/each}}
	</script>
	
	<script id="list-site-history" type="text/x-handlebars-template">
		{{#each result}}
			<div class="item">
				<div class="title" onclick="searchHistory(this);">
					<i class="icon iconfont icon-lubiao"></i><span>{{keyword}}</span>
				</div>
			</div>
		{{/each}}
	</script>
	
	<script id="list-querysite-templ" type="text/x-handlebars-template">
		{{#each result}}
			<div class="item">
				<div class="title" onclick="searchHistory(this);">
					<i class="icon iconfont icon-lubiao"></i><span>{{siteName}}</span>
				</div>
			</div>
		{{/each}}
	</script>
		

	<script type="text/javascript">
		
		var query = $.getLocationQueryData();
		
		var longitude = query.longitude;
		var latitude = query.latitude;
		var oldLongitude = query.longitude;
		var oldLatitude = query.latitude;
		var phone = query.phone;
		function flushList(url,params){
			//获取附近站点
			$.asyncrequest(url, params,function(data){
				data = JSON.parse(data);
				if(data.message!='success'){
					$.alert("暂无数据");
					$.AMUI.progress.done();
					return;
				}
				data = uniqResult(data);
				$('#number').html(data.result.length);
				var myTemplate = Handlebars.compile($('#list-site-templ').html());
				var html = myTemplate(data);
				$('#list').html(html);
				$.AMUI.progress.done();
			});
			
			//获取所有收藏站点
			var collections;
			url = 'taxi/json/getBusCollectionList';
			params={phone:phone};
			$.asyncrequest(url, params,function(data){
				if(data.retCode==0){
					collections = data.result;
				}
			});
				
			//获取经过站点的线路
			//url = 'taxi/json/nanda';
			$('#list .item .content').each(function(){
				var content = $(this);
				var siteName = content.attr('data-siteName');
				var siteId = content.attr('data-siteId');
				
				//获取所有线路
				var lines;
				params = {"siteName":siteName};
				url = "taxi/json/getLineBySiteIdName";
				$.asyncrequest(url, params,function(data){
					data = JSON.parse(data);
					data.siteId = siteId;
					var myTemplate = Handlebars.compile($('#list-line-templ').html());
					var html = myTemplate(data);
					html = html.substring(0,(html.length-3));
					content.html(html);
					var keyword = $("#keyword").val();
					lines = data.result;
				});
				
				for(var i=0; i < lines.length; i++) {
					var item = lines[i];
					url = "taxi/json/nanda?url="+escape("getSiteByLine.action?lineId="+item.lineId);
					params={};
					$.asyncrequest(url, params, function(sites){
						sites = JSON.parse(sites);
						if(sites.retCode==0){
							for(var i=0;i<sites.result.length;i++){
								var busSite = sites.result[i];
								if(busSite.siteName===siteName){
									var 
									busSite.siteId;
									break;
								}
							}
						}
					});
				}
				
				var items = new Array();
				for(var i=0; i < lines.length; i++) {
					var item = lines[i];
					var distance = 0;
					url = "taxi/json/nanda?url="+escape("getNearestBus.action?lineId="+item.lineId+"&siteId="+siteId+"&stream=0");
					params={};
					$.asyncrequest(url, params, function(distanceInfo){
						distanceInfo = JSON.parse(distanceInfo);
						if(distanceInfo.retCode == 0 && distanceInfo.result.redistance>0) {
							distance = distanceInfo.result.redistance;
							$(".line[lineId="+item.lineId+"]").html('距<span id="distance">'+distance+'</span>m');
						}
					});
					
					item.distance = distance;
					item.siteId=lineSiteId;
					var isCollect = isCollect(item.lineId, lineSiteId, collections);
					item.sc_display= isCollect ? "''":"none";
					item.qxsc_display= isCollect ? "none":"''";
					items.push(item);
				}
				data.result = items;

			});
			
		}
		
		function isCollect(lineId, lineSiteId, collections){
			var isCollect = false;
			for(var i=0;i<collections.lenght;i++){
				var coll_siteId = collections[i].siteId;
				var coll_lineId = collections[i].lineId;
				if(coll_siteId==lineSiteId && coll_lineId==lineId){
					isCollect=true;
					break;
				}
			}
			return isCollect;
		}
		
		function selectStream(selectSiteId, lineId, obj){
			$('#lineId').val(lineId);
			
			var url = 'taxi/json/nanda?url='+escape("busLineInfo.action?lineId="+lineId+"&typeId=&lineName=");
			var params = {};
			var selectSiteName = $(obj).parent().parent().attr("data-siteName");
			$.request(url,params,function(data) {
				data = JSON.parse(data);
				if(data.retCode != 0){
					$('#streamContent').html('获取失败');
					return;
				}
				data = data.result[0];
				//上行
				var startSiteName = data.startSiteName;
				var endSiteName = data.endSiteName;
				//下行
				var startSiteName1 = data.startSiteName1;
				var endSiteName1 = data.endSiteName1;
				
				var detailUrl = "busDetail.html?lineId="+lineId+"&siteId="+selectSiteId+"&siteName="+escape(selectSiteName)+"&phone="+phone+
				"&longitude="+oldLongitude+"&latitude="+oldLatitude +"&stream=";
				var html = '<div style="font-size: 2rem;margin-top: 2rem;"><a href="javascript:openDetail(\''+detailUrl+'0\');">'+(startSiteName+'-'+endSiteName)+'</a></div>';
				if(startSiteName1 && endSiteName1){
					html += '<div style="font-size: 2rem;margin-top: 2rem;"><a href="javascript:openDetail(\''+detailUrl+'1\');">'+(startSiteName1+'-'+endSiteName1)+'</a></div>';
				}
				$('#streamContent').html(html);
			});
								
			$('#streamContent').html('<i class="icon iconfont icon-loadd am-animation-spin"></i>获取中...');
			$('#streamModal').modal('open');
		}
		
		var url = '';
		var params = {};
		function init(){
			tanchuan();
			url = 'taxi/json/nanda?url='+escape("getNearestSite.action?lat="+latitude+"&lon="+longitude+"&coordinate=3");
			params = {};
			//params.lat = latitude;
			//params.lon = longitude;
			//params.coordinate = 3;
			flushList(url,params);
			
			renotice();
			setTimeout(function(){
				relocate();
			}, 30*1000);
		}
		function search(keyword){
			url = "taxi/json/getSiteInfoBySiteName";
        	params = {siteName:keyword,lineId:""};
        	if(!isNaN(keyword)) {
        		params = {siteName:"",lineId:keyword};
        	}
			flushList(url,params);
			$(".fujin").hide();
			saveToLocal(keyword);
		}
		

		$('.icon-refresh').click(function(){
			flushList(url,params);
		});

		$('.icon-search').click(function(){
			var keyword = $('#keyword').val();
			if(!keyword){
				init();
				return;
			}
			
			search(keyword);
		});
		
		$.AMUI.progress.start();
		
		//IOS
		if($.isIOS()){
			if(navigator.geolocation){
	        	navigator.geolocation.getCurrentPosition(
					function(p){
		            	longitude = p.coords.longitude;
						latitude = p.coords.latitude;
						init();
						
						//GPS坐标转换为百度坐标
						/* var gpsPoint = new BMap.Point(longitude,latitude);
						var pointArr = [];
	        			pointArr.push(gpsPoint);
	        			var convertor = new BMap.Convertor();
        				convertor.translate(pointArr, 1 , 5 , translateCallback); 
	         */
					},
		            function(e){
		            	var msg = e.code + "," + e.message;
		            	$.alert('获取位置失败：'+msg);
		            	init();        
					}
	        	);
		    }else{
		    	$.alert('获取位置失败');
		    	init();        
		    }
		}
		
		//Android
		else{
			var point = transferBaidu2WGS84(longitude, latitude);
			longitude = point[0];
			latitude = point[1];
	        init();
		}
        
        /* function translateCallback(data){
        	if(data.status === 0) {
        		var point  = data.points[0];
        		var lng = point.lng;
        		var lat = point.lat;
		    	longitude = lng;
		    	latitude = lat;
			}
			init();
        } */
        
		function openDetail(url){
        	
			$('#streamModal').modal('close');
        	location.href=url;
        	
        }
        
        //加载搜索历史
        var inited = false;
        $('#keyword').focus(function(){
        	$(".sites").hide();
        	var key = "search-history";
	        if(!window.localStorage){
	 			alert('This browser does NOT support search history');
			} else {
				if(!inited) {
					var value = localStorage.getItem(key);
					if(value) {
						var historyArr = value.split("|");
						var jsonArr = toJsonArr(historyArr);
						var data = {"result": jsonArr};
						var myTemplate = Handlebars.compile($('#list-site-history').html());
						var html = myTemplate(data);
						$("#historylist").html(html);
						$("#clearHistory").html("清空搜索历史");
					} else {
						$("#clearHistory").html("暂无搜索记录");
					}
					inited=true;
				} 
				$(".am-content").hide();
	        	$(".history").show();
			}
        });
        
        $('#keyword').keyup(function(){
        	$(".sites").show();
        	var keyword = $(this).val();
        	if(keyword=='') {
        		$(".sites").hide();
        		$(".sites").html("");
        		$(".history").show();
        		return;
        	} else {
        		$(".history").hide();
        	}
        	var url = "taxi/json/getSiteInfoBySiteName";
        	var params = {siteName:keyword,lineId:""};
        	if(!isNaN(keyword)) {
        		params = {siteName:"",lineId:keyword};
        	}
        	$.request(url, params,function(data){
        	data = JSON.parse(data);
        	//var data = {"result":[{"siteName":"我的"}]};
	    	if(data.message!='success'){
				$.alert(data.message);
				$.AMUI.progress.done();
				return;
			}
			if(data.result.length>0){
				data = uniqResult(data);
				var myTemplate = Handlebars.compile($('#list-querysite-templ').html());
				var html = myTemplate(data);
				$(".am-content").hide();
				$('.sites').html(html);
			}
			$.AMUI.progress.done();
        	});
        });
        
        function uniqResult(data) {
        	//去重
	    	var result = data.result;
	    	var uniqArr = [];
	    	var uniqResult = [];
	    	for(var i=0;i<result.length;i++) {
	    		if(uniqArr.indexOf(result[i].siteName)==-1){
	    			uniqArr.push(result[i].siteName);
	    			uniqResult.push(result[i]);
	    		}
	    	}
	    	data.result = uniqResult;
	    	return data;
        }
        
        $('#keyword').blur(function(){
        	setTimeout(function(){
        		$(".am-content").show();
        		$(".history").hide();
        		$(".sites").hide();
        	},300);
        });
        
        function searchHistory(obj) {
        	$(this).hide();
        	var key = $(obj).find("span").html();
        	$("#keyword").val(key);
        	search(key);
        	$(".am-content").show();
        }
        
        //记录搜索历史
        function saveToLocal(keyword) {
        	if(keyword==null || keyword=='') {
        		return;
        	}
        	var key ="search-history";
        	if(window.localStorage) {
        		var value = localStorage.getItem(key);
        		if(value) {
        			var historyArr = value.split("|");
        			historyArr.splice(0, 0, keyword);
        			historyArr = unique(historyArr);
        			historyArr = historyArr.splice(0, 10);
        			var newValue = "";
        			for(i=0; i<historyArr.length; i++) {
        				newValue += historyArr[i] + "|";
        			}
        			localStorage.setItem(key, newValue.substring(0,newValue.length-1));
        		} else {
        			localStorage.setItem(key,keyword);
        		}
        	}
        }
        
        //清除搜索历史
        function clearHistory() {
        	var key ="search-history";
        	$("#historylist").html("");
        	if(window.localStorage) {
        		localStorage.removeItem(key);
        	}
        }
        
        function toJsonArr(arr) {
        	var jsonArr = [];
        	for(i=0; i<arr.length; i++) {
        		var json = {"keyword" : arr[i]};
        		jsonArr.push(json);
        	}
        	return jsonArr;
        }
        
        //数组去重
        function unique(arr) {
    		var result = [], hash = {};
    		for (var i = 0, elem; (elem = arr[i]) != null; i++) {
        		if (!hash[elem]) {
            			result.push(elem);
            			hash[elem] = true;
        		}
    		}
    		return result;
	}
	
	//收藏、取消收藏
	function shouc(obj, siteId, lineId) {
		if(!phone || phone=='') {
			$.alert("手机号不能为空");
			return;
		}
		var url = "taxi/json/addBusCollection";
		var params = {lineId:lineId,siteId:siteId,phone:phone};
		$.request(url,params,function(data) {
			if(data.retCode != 0){
				$.alert(data.message);
				return;
			}
			$(obj).hide();
			$(obj).next().show();
			$.alert("收藏成功");
		});
	}
	
	function qxshouc(obj, siteId, lineId) {
		if(!phone || phone=='') {
			$.alert("手机号不能为空");
			return;
		}
		var url = "taxi/json/delBusCollection";
		var params = {lineId:lineId,siteId:siteId,phone:phone};
		$.request(url,params,function(data) {
			if(data.retCode != 0){
				$('#streamContent').html('取消收藏失败');
				return;
			}
			$(obj).hide();
			$(obj).prev().show();
			$.alert("取消成功");
		});
	}
	
	$("#xlgh").click(function(){
		location.href = "bustransfer.html?longitude=" + oldLongitude + "&latitude=" + oldLatitude + "&phone=" + phone + "&tt="+Math.random();
	});
	
	$("#wdsc").click(function(){
		location.href = "collection.html?longitude=" + oldLongitude + "&latitude=" + oldLatitude + "&phone=" + phone + "&tt="+Math.random();
	});
	
	function relocate(){
		if($.isIOS()){
			if(navigator.geolocation){
	        	navigator.geolocation.getCurrentPosition(
					function(p){
		            	longitude = p.coords.longitude;
						latitude = p.coords.latitude;
					},
		            function(e){
		            	var msg = e.code + "," + e.message;
		            	$.alert('获取位置失败：'+msg);
					}
	        	);
		    } else {
		    	$.alert('获取位置失败');
		    	return;      
		    }
		} else {
			var url = '';
			var params = {};
			$.request(url,params,function(data){
				if(data.retCode!=0){
					$.alert('获取位置失败');
					return;
				}
				longitude = data.longitude;
				latitude = data.latitude;
			});
		}
	}
	function renotice() {
		var url = "taxi/json/getBusNotice";
		var params = {type:'1001'};
		$.request(url,params,function(data) {
			if(data.retCode != 0 || !data.result){
				return;
			}
			var starttime = parseDate(data.result.startTime);
			var endtime = parseDate(data.result.endTime);
			var content = data.result.content;
			
			var nowDate = new Date();
			if(nowDate>=starttime && nowDate<=endtime){
				$(".notice marquee").html("公告："+content);
				$('.notice').show();
			} else {
				$('.notice').hide();
			}
		});
	}
	
	function tanchuan() {
		var isTanchu = sessionStorage.isTanchu;
		if(isTanchu){
			return false;
		} else {
			sessionStorage.isTanchu=true;
		}
		var url = "taxi/json/getBusNotice";
		var params = {type:'1002'};
		$.request(url,params,function(data) {
			if(data.retCode != 0 || !data.result){
				return;
			}
			var starttime = parseDate(data.result.startTime);
			var endtime = parseDate(data.result.endTime);
			var content = data.result.content;
			
			var nowDate = new Date();
			if(nowDate>=starttime && nowDate<=endtime){
				$("#news").html(content);
				$("#element_to_pop_up").bPopup();
			}
		});
	}
	
	function parseDate(dateStr) {
		var year = dateStr.substring(0,4);
		var month = dateStr.substring(4,6);
		var day = dateStr.substring(6,8);
		var hh = dateStr.substring(8,10);
		var mm = dateStr.substring(10,12);
		var ss = dateStr.substring(12,14);
		return new Date(year, parseInt(month)-1, day, hh, mm, ss);
	}
	
	var start = true;
	function changeStatus(obj){
		if(start){
			obj.stop();
			start = false;
		} else {
			obj.start();
			start = true;
		}
	}
	
	//-->
	</script>
	

 
</body>
</html>
